package com.cskaoyan.bean.goods.base;

import com.github.pagehelper.PageInfo;
import lombok.Data;

import java.util.List;

/**
 * @Description:
 * @author: Jason 805636901@qq.com
 * @create: 2021-10-19-8:13 PM
 */
@Data
public class CommentPageData<T> {
    Integer limit;
    Integer page;
    Integer pages;
    Integer total;
    List<T> list;

    public static<T> CommentPageData ok(List<T> comments) {
        PageInfo<T> commentPageInfo = new PageInfo<T>(comments);

        CommentPageData<T> data = new CommentPageData<>();
        data.setPage(commentPageInfo.getPageNum());
        data.setLimit(commentPageInfo.getPageSize());
        data.setPages(commentPageInfo.getPages());
        data.setTotal((int) commentPageInfo.getTotal());
        data.setList(comments);

        return data;
    }

}
